<?php

namespace Account\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AccountController extends AbstractActionController
{
    protected $accountTable;
    protected $check;
    protected $thrift;
    protected $account;

    public function getAccountTable()
    {
        if (!$this->accountTable) {
            $sm = $this->getServiceLocator();
            $this->accountTable = $sm->get('Account\Model\AccountTable');
        }
        return $this->accountTable;
    }

    public function indexAction()
    {
        $this->account = $this->getAccountTable()->fetchAll();
        $view = new ViewModel(array(
            'account' => $this->account
        ));
        return $view;
    }

    public function checkAction()
    {
        $this->check = $this->getAccountTable()->getCheck();
        $view = new ViewModel(array(
            'check' => $this->check
        ));
        return $view;
    }

    public function thriftAction()
    {
        $this->thrift = $this->getAccountTable()->getThrift();
        $view = new ViewModel(array(
            'thrift' => $this->thrift
        ));
        return $view;
    }
}